package com.yunnuo.system.dict.dao;

import com.yunnuo.system.dict.entity.DictData;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by w_weihf on 2018/8/3.
 */
@Repository
@Transactional
public interface IDictDataDao extends JpaRepository<DictData,String> {

    /**
     * 根据code查询数据字典
     * @param dictCode
     * @return
     */
    List findAllByDictCode(String dictCode);

    /**
     * 根据类型查询所有数据
     * @param dictType
     * @return
     */
    List findAllByDictType(String dictType);


    /**
     * 分页查询
     * @param pageable
     * @return
     */
    @Override
    Page<DictData> findAll(Pageable pageable);


    /**
     * 带条件的分页查询
     * @param dictCode
     * @param pageable
     * @return
     */
    Page<DictData> findAllByDictCode(String dictCode,Pageable pageable);
    long countAllByDictCode(String dictCode);

    /**
     * 带条件的分页查询
     * @param dictType
     * @param pageable
     * @return
     */
    Page<DictData> findAllByDictType(String dictType,Pageable pageable);
    long countAllByDictType(String dictType);


    Page<DictData> findAllByDictTypeAndDictCode(String dictCode,String dictType,Pageable pageable);
    long countAllByDictTypeAndDictCode(String dictCode,String dictType);

}
